function ajaxDeleteImage(params) {
	var d = params.split(',');
	Ext.Msg.confirm("警告", "你确删除吗？", function(btn) {
		if (btn == 'yes') {
			Ext.Ajax.request( {
				url : basePath + 'base/deleteImage.action?image.id='
						+ params.split(',')[0] + '&who=' + params.split(',')[1]
						+ '&mode=' + params.split(',')[2],
				method : 'post',
				callback : function(op, success, response) {
					var msg = eval('(' + response.responseText + ')');
					if (msg.result == 'delete') {
						Ext.StoreMgr.get(d[1] + 'ImagesStore').reload();
						Ext.Msg.alert('提示', '图片彻底删除了');
					} else if (msg.result == 'update') {
						Ext.StoreMgr.get(d[1] + 'ImagesStore').reload();
						Ext.Msg.alert('提示', '图片放回了回收站');
					} else if (msg.result == 'none') {
						Ext.Msg.alert('提示', '未删除任何东西');
					}
				}
			});
		}
	})
}

function ajaxDeleteXxx(id, who, mode) {
	Ext.Msg.confirm("警告", "你确删除吗？", function(btn) {
		if (btn == 'yes') {
			Ext.Ajax.request( {
				url : basePath + who + '/delete.action?' + who + '.id=' + id
						+ '&who=' + who	+ '&mode=' + mode,
				method : 'post',
				callback : function(op, success, response) {
					var msg = eval('(' + response.responseText + ')');
					if (msg.result == 'delete') {
						Ext.StoreMgr.get(who + 'Store').reload();
						Ext.Msg.alert('提示', who + '彻底删除了');
					} else if (msg.result == 'update') {
						Ext.StoreMgr.get(who + 'Store').reload();
						Ext.Msg.alert('提示', who + '放回了回收站');
					} else if (msg.result == 'none') {
						Ext.Msg.alert('提示', '未删除任何东西');
					}
				}
			});
		}
	})
}

function ajaxDeleteXxxInRecycle(id, who, mode) {
	Ext.Msg.confirm("警告", "你确删除吗？", function(btn) {
		if (btn == 'yes') {
			Ext.Ajax.request( {
				url : basePath + who + '/delete.action?' + who + '.id=' + id
						+ '&who=' + who	+ '&mode=' + mode,
				method : 'post',
				callback : function(op, success, response) {
					var msg = eval('(' + response.responseText + ')');
					if (msg.result == 'delete') {
						Ext.StoreMgr.get(who + 'StoreVisible').reload();
						Ext.Msg.alert('提示', who + '彻底删除了');
					} else if (msg.result == 'update') {
						Ext.StoreMgr.get(who + 'StoreVisible').reload();
						Ext.Msg.alert('提示', who + '放回了回收站');
					} else if (msg.result == 'none') {
						Ext.Msg.alert('提示', '未删除任何东西');
					}
				}
			});
		}
	})
}

function ajaxDeleteLink(id, imageName, who, mode) {
	Ext.Msg.confirm("警告", "你确删除吗？", function(btn) {
		if (btn == 'yes') {
			Ext.Ajax.request( {
				url : basePath + who + '/delete.action?' + who + '.id=' + id
						+ '&who=' + who	+ '&mode=' + mode + '&imageName=' + imageName,
				method : 'post',
				callback : function(op, success, response) {
					var msg = eval('(' + response.responseText + ')');
					if (msg.result == 'delete') {
						Ext.StoreMgr.get(who + 'Store').reload();
						Ext.Msg.alert('提示', who + '彻底删除了');
					} else if (msg.result == 'update') {
						Ext.StoreMgr.get(who + 'Store').reload();
						Ext.Msg.alert('提示', who + '放回了回收站');
					} else if (msg.result == 'none') {
						Ext.Msg.alert('提示', '未删除任何东西');
					}
				}
			});
		}
	})
}

function ajaxPreDeleteCategory(id, who, mode, categoryName) {
	Ext.Msg.confirm("警告", "你确删除吗？", function(btn) {
		if (btn == 'yes') {
			Ext.Ajax.request( {
				url : basePath + 'base/preDeleteCategory.action?category.id=' + id
						+ '&whoCategory=' + who,
				method : 'post',
				callback : function(op, success, response) {
					var result = eval('(' + response.responseText + ')');
					var realName;
					switch(who) {
						case 'product' : realName = '产品'; break;
						case 'news' : realName = '新闻'; break;
						case 'equipment' : realName = '设备'; break;
					}
					new Ext.ux.PreDelete({
						id:'preDelete',
						categoryId:id,
						msgData:result,
						categoryName:categoryName,
						whoValue:who,
						deleteMode:mode,
						who:realName
					}).show(this);
				}
			});
		}
	})
}

function ajaxDeleteCategory(id, who, mode) {
	Ext.Msg.confirm("警告", "你确删除吗？", function(btn) {
		if (btn == 'yes') {
			Ext.Ajax.request( {
				url : basePath + 'base/deleteCategory.action?category.id=' + id
						+ '&whoCategory=' + who + '&mode=' + mode,
				method : 'post',
				callback : function(op, success, response) {
					var msg = eval('(' + response.responseText + ')');
					if (msg.result == 'delete') {
						Ext.getCmp('preDelete').close();
						Ext.StoreMgr.get('categoryStore').reload();
						Ext.Msg.alert('提示', who + '彻底删除了');
					} else if (msg.result == 'update') {
						Ext.getCmp('preDelete').close();
						Ext.StoreMgr.get('categoryStore').reload();
						Ext.Msg.alert('提示', who + '放回了回收站');
					} else if (msg.result == 'none') {
						Ext.Msg.alert('提示', '未删除任何东西');
					}
				}
			});
		}
	})
}

function ajaxRecoverXxx(who, id) {
	Ext.Msg.confirm("警告", "你确回收吗？", function(btn) {
		if (btn == 'yes') {
			Ext.Ajax.request( {
				url : basePath + who + '/recover.action?' + who + '.id=' + id,
				method : 'post',
				callback : function(op, success, response) {
					var msg = eval('(' + response.responseText + ')');
					if (msg.success == 'true') {
						Ext.StoreMgr.get(who + 'StoreVisible').reload();
						Ext.Msg.alert('提示', who + '已经回收');
					} else if (msg.success == 'false') {
						Ext.Msg.alert('提示', who + '回收失败');
					}
				}
			});
		}
	})
}

function ajaxRecoverXxxHasCategory(who, id) {
	Ext.Msg.confirm("警告", "你确回收吗？", function(btn) {
		if (btn == 'yes') {
			Ext.Ajax.request( {
				url : basePath + who + '/recover.action?' + who + '.id=' + id,
				method : 'post',
				callback : function(op, success, response) {
					var msg = eval('(' + response.responseText + ')');
					if (msg.success == 'true') {
						Ext.StoreMgr.get(who + 'StoreVisible').reload();
						Ext.Msg.alert('提示', who + '已经回收');
					} else if (msg.success == 'false') {
						if(msg.msg == 'null') {
							Ext.Msg.alert('提示', who + '回收不能为空');
						} else {
							Ext.Msg.alert('提示', who + '回收实体的类别属性不能在回收站中<br/>' +
							'请先回收所对应的类别');
						}
					}
				}
			});
		}
	})
}

function encode(value) {
    result = [];
    for(var i=0,l=value.length;i<l;i++){
        result.push(value.charCodeAt(i).toString(2));
    }
    return result.join(',');
}

function getType(o) {
	var _t;
	return ((_t = typeof (o)) == "object" ? Object.prototype.toString.call(o)
			.slice(8, -1) : _t).toLowerCase();
}

function replaceAll(str, sptr, sptr1) {
	while (str.indexOf(sptr) >= 0) {
		str = str.replace(sptr, sptr1);
	}
	return str;
}